# encoding: UTF-8:
import binascii

class GpsRecvList:
    def __init__(self):
        self.gpsRecvList = ''
    def recvSlipData(self,recvData):
        self.gpsRecvList += recvData
        secondIndex = self.gpsRecvList[1:].find('\xc0')
        res = ''
        if self.gpsRecvList[0] == '\xc0' and secondIndex!=-1:
            res = self.gpsRecvList[0:secondIndex+2]
            self.gpsRecvList = self.gpsRecvList[secondIndex+2:]
        elif self.gpsRecvList[0] != '\xc0' and secondIndex==-1:
            self.gpsRecvList = ''
        elif self.gpsRecvList[0]!= '\xc0' and secondIndex != -1:
            self.gpsRecvList = self.gpsRecvList[secondIndex+1:]
        return res
if __name__ == '__main__':
    gpsRecvModel = GpsRecvList()
    print binascii.b2a_hex(gpsRecvModel.recvSlipData('\xc0\xc0'))
    print binascii.b2a_hex(gpsRecvModel.recvSlipData('\x55\x55'))
    print binascii.b2a_hex(gpsRecvModel.recvSlipData('\xc0'))
    print binascii.b2a_hex(gpsRecvModel.recvSlipData('\x55\x55'))
    print binascii.b2a_hex(gpsRecvModel.recvSlipData('\xc0'))
